// pages/map-control/map-control.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    location: {
      latitude: 40.040415,
      longitude: 116.273511
    },
    isShowScale: false,
    isShowCompass: false,
    isShowPosition: false,
    showActionSheet: false,
    options: null
  },
  preview() {
    wx.previewImage({
      current: this.data.options.img, // 当前显示图片的http链接
      urls: [this.data.options.img] // 需要预览的图片http链接列表
    })
  },
  onLoad(options) {
    console.log(options)
    this.setData({
      options
    })
    // this.onChangeShowPosition()
  },
  onBack() {
    console.log(1)
    wx.navigateBack({
      delta: 1
    })
  },
  onChangeShowScale(event) {
    this.setData({
      isShowScale: event.detail.value
    });
  },
  onBack() {
    console.log(1)
    wx.navigateBack({
      delta: 1
    })
  },

  // 激活指南针
  onChangeShowCompass(event) {
    this.setData({
      isShowCompass: event.detail.value
    });
  },
  // 激活定位控件
  onChangeShowPosition() {

    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        const {
          latitude,
          longitude
        } = res;
        this.setData({
          location: {
            latitude,
            longitude
          }
        });
      }
    });
    this.setData({
      showPosition: value
    });
  }
});